def run(params:list[str]):
    from sklearn import datasets,tree
    from sklearn.metrics import accuracy_score, precision_score,recall_score,f1_score
    from sklearn.metrics import mean_squared_error, r2_score
    
    ### 1.7.2 决策树回归
    from ApiBase import apiBase
    try:
        data=apiBase.argv_json(params,1,{"0.1,0.2":"0.1","0.3,0.4":"0.2","0.4,0.5":"0.2","0.6,0.7":"0.1","0.8,0.9":"0.1"})
        #apiBase.log("param1="+str(data))
        diabetes_X=[]
        diabetes_y=[]
        for key in data.keys():
            numbers = [float(num) for num in key.split(',')]
            diabetes_X.append(numbers)
            val=float(data[key])
            diabetes_y.append(val)

        n_samples = len(diabetes_X)
        sz=int(0.6 * n_samples)
        
        ### 1.8.2 随机森林回归
        # 加载diabetes数据集
        # diabetes_X, diabetes_y = datasets.load_diabetes(return_X_y=True)
        # print(diabetes_X)
        # print(diabetes_y)
        
        # 特征数据划分训练集和测试集
        diabetes_X_train = diabetes_X[:sz] #后20个样本作为测试集，其余作为训练集
        diabetes_X_test = diabetes_X[sz:]

        # 标签（类别）数据划分训练集和测试集
        diabetes_y_train = diabetes_y[:sz] #后20个样本作为测试集，其余作为训练集
        diabetes_y_test = diabetes_y[sz:]
        #创建模型，DecisionTreeRegressor回归器
        clf = tree.DecisionTreeRegressor(max_depth=2)   #max_depth树的最大深度，还有很多其他参数，此处使用默认值                                                    

        #模型训练
        clf.fit(diabetes_X_train, diabetes_y_train)  #对于回归问题，预测值通常是这k个最近邻的目标值的平均值（或加权平均值）                            

        #模型预测
        y_pred = clf.predict(diabetes_X_test)      

        # 模型评估MSE指标
        import json
        retdata={}
        retdata["Mean squared error"]=mean_squared_error(diabetes_y_test, y_pred)
        # 模型评估R2指标
        retdata["Coefficient of determination"]= r2_score(diabetes_y_test, y_pred)
        
        return json.dumps(retdata,ensure_ascii=False)
    except Exception as e:
        return f"function error:{e}"